package web_k;

import pojo_k.HomeUser;
import pojo_k.HomeUserIncome;
import service_k.HomeUserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/homeUserIncomeServlet")
public class HomeUserIncomeServlet extends HttpServlet {
    private HomeUserService service = new HomeUserService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String homeuserName = request.getParameter("homeuserName");
        float homeuserCun = Float.parseFloat(request.getParameter("homeuserCun"));
        String time = request.getParameter("time");


        HomeUserIncome homeUserIncome = new HomeUserIncome();
        homeUserIncome.setHomeuserName(homeuserName);
        homeUserIncome.setHomeuserCun(homeuserCun);
        homeUserIncome.setTime(time);

        service.homeUserIncomeAdd(homeUserIncome);

        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("存款成功！");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
